home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / COMMON / TOOLS / VCM / VCM.MDB / VcmComponentContainer / 14_Cabinet / MAINFRM.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-18  |  5.2 KB  |  204 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes and
  4. // Templates (MFC&T).
  5. // Copyright (C) 1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // MFC&T Reference and related electronic documentation provided
  10. // with the library.  See these sources for detailed information
  11. // regarding the MFC&T product.
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "DBViewer.h"
  16. #include "OptionDg.h"
  17.  
  18. #include "MainFrm.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMainFrame
  28.  
  29. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  30.  
  31. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  32.     //{{AFX_MSG_MAP(CMainFrame)
  33.     ON_WM_CREATE()
  34.     ON_COMMAND(ID_VIEW_OPTIONS, OnViewOptions)
  35.     ON_COMMAND(ID_APP_CLONE, OnAppClone)
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. static UINT indicators[] =
  40. {
  41.     ID_SEPARATOR,           // status line indicator
  42.     ID_INDICATOR_CAPS,
  43.     ID_INDICATOR_NUM,
  44.     ID_INDICATOR_SCRL,
  45. };
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CMainFrame construction/destruction
  49.  
  50. CMainFrame::CMainFrame()
  51. {
  52.     // TODO: add member initialization code here
  53.  
  54. }
  55.  
  56. CMainFrame::~CMainFrame()
  57. {
  58. }
  59.  
  60. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  61. {
  62.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  63.         return -1;
  64.  
  65.     if (!m_wndToolBar.Create(this) ||
  66.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  67.     {
  68.         TRACE0("Failed to create toolbar\n");
  69.         return -1;      // fail to create
  70.     }
  71.  
  72.     if (!m_wndStatusBar.Create(this) ||
  73.         !m_wndStatusBar.SetIndicators(indicators,
  74.           sizeof(indicators)/sizeof(UINT)))
  75.     {
  76.         TRACE0("Failed to create status bar\n");
  77.         return -1;      // fail to create
  78.     }
  79.  
  80.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  81.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  82.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  83.  
  84.     // TODO: Delete these three lines if you don't want the toolbar to
  85.     //  be dockable
  86.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  87.     EnableDocking(CBRS_ALIGN_ANY);
  88.     DockControlBar(&m_wndToolBar);
  89.  
  90.     return 0;
  91. }
  92.  
  93. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  94.     CCreateContext* pContext)
  95. {
  96.     // create a splitter with 1 row, 2 columns
  97.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  98.     {
  99.         TRACE0("Failed to CreateStaticSplitter\n");
  100.         return FALSE;
  101.     }
  102.  
  103.     // add the first splitter pane - the default view in column 0
  104.     if (!m_wndSplitter.CreateView(0, 0,
  105.         pContext->m_pNewViewClass, CSize(200, 50), pContext))
  106.     {
  107.         TRACE0("Failed to create first pane\n");
  108.         return FALSE;
  109.     }
  110.  
  111.     // add the second splitter pane - an input view in column 1
  112.     if (!m_wndSplitter.CreateView(0, 1,
  113.         RUNTIME_CLASS(CDBListView), CSize(0, 0), pContext))
  114.     {
  115.         TRACE0("Failed to create second pane\n");
  116.         return FALSE;
  117.     }
  118.  
  119.     // activate the input view
  120.     SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
  121.  
  122.     return TRUE;
  123. }
  124.  
  125. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  126. {
  127.     // TODO: Modify the Window class or styles here by modifying
  128.     //  the CREATESTRUCT cs
  129.  
  130.     return CFrameWnd::PreCreateWindow(cs);
  131. }
  132.  
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CMainFrame diagnostics
  135.  
  136. #ifdef _DEBUG
  137. void CMainFrame::AssertValid() const
  138. {
  139.     CFrameWnd::AssertValid();
  140. }
  141.  
  142. void CMainFrame::Dump(CDumpContext& dc) const
  143. {
  144.     CFrameWnd::Dump(dc);
  145. }
  146.  
  147. #endif //_DEBUG
  148.  
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CMainFrame message handlers
  151.  
  152. void CMainFrame::OnViewOptions()
  153. {
  154.     CPropertySheet propSheet(_T("DaoView - Options"));
  155.     COptionsDlg pageOptions;
  156.     propSheet.AddPage(&pageOptions);
  157.  
  158.     CDBViewApp* pApp = (CDBViewApp *)AfxGetApp();
  159.  
  160.     pageOptions.m_bShowWarnings = pApp->m_bShowWarnings;
  161.     pageOptions.m_bShowSystemObjects = pApp->m_bShowSystemObjects;
  162.     pageOptions.m_bOpenODBC= pApp->m_bOpenODBC;
  163.     pageOptions.m_nMaxRecords= pApp->m_nMaxRecords;
  164.  
  165.     if (propSheet.DoModal() == IDOK)
  166.     {
  167.         BOOL bRebuildList = FALSE;
  168.         if (pApp->m_bShowSystemObjects != pageOptions.m_bShowSystemObjects)
  169.             bRebuildList = TRUE;
  170.  
  171.         pApp->m_bShowSystemObjects = pageOptions.m_bShowSystemObjects;
  172.  
  173.         if (bRebuildList)
  174.             ((CDBViewDoc*) GetActiveDocument())->RefreshViews();
  175.  
  176.         pApp->m_bShowWarnings = pageOptions.m_bShowWarnings;
  177.         pApp->m_bOpenODBC = pageOptions.m_bOpenODBC;
  178.         pApp->m_nMaxRecords = pageOptions.m_nMaxRecords;
  179.     }
  180. }
  181.  
  182. void CMainFrame::OnAppClone()
  183. {
  184.     STARTUPINFO si;
  185.     PROCESS_INFORMATION pi;
  186.  
  187.     // Initialize the STARTUPINFO structure.
  188.     memset(&si, 0, sizeof(si));
  189.     si.cb = sizeof(si);
  190.  
  191.     CreateProcess(
  192.         NULL,   // pointer to name of executable module
  193.         (LPTSTR) AfxGetApp()->m_pszAppName, // pointer to command line string
  194.         NULL,   // pointer to process security attributes
  195.         NULL,   // pointer to thread security attributes
  196.         FALSE,  // handle inheritance flag
  197.         0,      // creation flags
  198.         NULL,   // pointer to new environment block
  199.         NULL,   // pointer to current directory name
  200.         &si,    // pointer to STARTUPINFO
  201.         &pi     // pointer to PROCESS_INFORMATION
  202.        );
  203. }
  204.